package com.inspector.app.ui.chat;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;

import com.inspector.app.R;
import com.inspector.app.databinding.ActivityVideoBinding;
import com.inspector.app.ui.base.BaseDJActivity;
import com.inspector.app.ui.chat.entity.DataBean;
import com.inspector.app.ui.widget.SmartTouchLayout;

public class VideoActivity extends BaseDJActivity {

    private ActivityVideoBinding viewDataBinding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initStatusBar(false);
        viewDataBinding = DataBindingUtil.setContentView(this, R.layout.activity_video);
        viewDataBinding.setLifecycleOwner(this);
        Bundle extras = getIntent().getExtras();
        DataBean dataBean = extras.getParcelable("DataBean");
        initView(dataBean);
    }

    private void initView(DataBean dataBean) {
        if (dataBean == null) {
            finish();
            return;
        }
        viewDataBinding.vp.initializePlayer(this, dataBean.url);
        viewDataBinding.stl.setEndViewLocalSize(dataBean.width, dataBean.height, dataBean.localX, dataBean.localY, SmartTouchLayout.EndViewScaleSide.Width);
        viewDataBinding.stl.setMoveExitEnable(true);
        viewDataBinding.stl.setZoomEnable(false);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        viewDataBinding.vp.releasePlayer();
    }
}
